package com.dgut.smart_house.mapper;

import com.dgut.smart_house.domain.Datas;
import com.dgut.smart_house.dto.DataTypeDto;
import com.dgut.smart_house.dto.RealDataDto;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface DatasMapper {

    @Select("select * from datas where node=#{id}")
    public List<Datas> findByNodeId(@Param("id") Integer id);


    public List<Datas> findByTime(@Param("datetime") String datetime, @Param("nodeId") Integer nodeId);

    @Insert("insert into datas (value,node,type,dev_id,from_user) values (#{value},#{node},#{type},#{devId},#{fromUser})")
    public int createData(Datas dateas);

    public List<DataTypeDto> findData2DevId(@Param("devId") Integer devId);

    public List<RealDataDto> findRealDatas(@Param("userId") Integer userId);

    @Delete("delete from datas where dev_id=#{devId}")
    public int deleteDatasByDevId(Integer devId);
}
